package org.kernely.test.settings;

import org.kernely.ui.mvp.IKernelyView;

import com.vaadin.event.ShortcutAction.KeyCode;
import com.vaadin.ui.Button;
import com.vaadin.ui.Component;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.Panel;
import com.vaadin.ui.TextField;

/**
 * The SettingsView class
 */
public class SettingsView extends GridLayout implements IKernelyView{
	/**
	 * The Serial Version ID
	 */
	private static final long serialVersionUID = 21561234564121L;

	public final static Class<? extends IKernelyView> ID_VIEW = SettingsView.class;

	private TextField settings1;
	private TextField settings2;
	private Label result;
	private Button setButton;
	
	/**
	 * This method initializes the View of settings. No logic, only display.
	 */
	public SettingsView(){
		result = new Label();
		settings1 = new TextField("Property 1");
		settings2 = new TextField("Property 2");
		Panel northPanel = new Panel();
		Panel southPanel = new Panel();
		Panel eastPanel = new Panel();
		setButton = new Button("Set properties");
		setButton.setClickShortcut(KeyCode.ENTER);
		this.setColumns(4);
		this.setRows(2);
		this.addComponent(northPanel,0,0);
		this.addComponent(southPanel,0,1);
		this.addComponent(eastPanel,1,0,3,1);
		northPanel.addComponent(new Label("Test Bundle settings page"));
		southPanel.addComponent(new Label("Step 1 : Type values in the two fields below and then click on the Set Properties button."));
		southPanel.addComponent(new Label("Step 2 : Check the a file named BundleTestSettings.properties exists and contains the two properties you entered. Below the button you should also see the two values."));
		southPanel.addComponent(new Label("Step 3 : Click on the Home button to go back home."));
		eastPanel.addComponent(settings1);
		eastPanel.addComponent(settings2);
		eastPanel.addComponent(setButton);
		eastPanel.addComponent(result);
		this.setSizeFull();
	}

	/**
	 * @see org.kernely.core.service.IKernelyView#getComponent()
	 */
	public final Component getComponent() {
		return this;
	}

	//Getters and setters
	
	/**
	 * Gets the settings1 field
	 * @return the settings1 field
	 */
	public final TextField getSettings1() {
		return settings1;
	}

	/**
	 * Gets the settings2 field
	 * @return the settings2 field
	 */
	public final TextField getSettings2() {
		return settings2;
	}

	/**
	 * Gets the result label
	 * @return the result label
	 */
	public final Label getResult() {
		return result;
	}

	/**
	 * Gets the setButton
	 * @return the setButton
	 */
	public final Button getSetButton() {
		return setButton;
	}
}
